package hku.cs.lunuo.rank;

public class Jaccard extends Voter {

	@Override
	public Label vote(VotedUnit u, VotedGlobal g) {
		int falseCases = u.tf.getFlsTimes();
		int trueCases = u.tf.getTruTimes();
		float susc;
		if (g.totalTF.getFlsTimes() == 0 && trueCases == 0)
			susc = 0;
		else
			susc = (float) falseCases / (g.totalTF.getFlsTimes() + trueCases);
		return new DefaultLabel(susc);
	}
	
	private float sum(int n) {
		float sum = 0;
		for(int i=1; i<=n; i++) {
			sum+=1/(float)i;
		}
		return sum;
	}
}
